package structure.proxy.dynamic;

import java.lang.reflect.Proxy;

/**
 * Created by lie on 2017/10/31.
 * 负责动态代理的杂物
 */
public class ProxyFactory {

    //维护一个目标对象
    private Object target;
    public ProxyFactory(Object target){
        this.target=target;
    }

    //给目标对象生成代理对象
    public Object getProxyInstance(){
        return Proxy.newProxyInstance(
                target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                new DynamicProxyLiu(target)
        );
    }

}
